home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 1320 / 1320.xpi / chrome / gmanager.jar / content / utils / alerts.js < prev    next >
Text File  |  2010-01-22  |  2KB  |  79 lines

  1. // Gmail Manager
  2. // By Todd Long <longfocus@gmail.com>
  3. // http://www.longfocus.com/firefox/gmanager/
  4.  
  5. var gmanager_Alerts = new function()
  6. {
  7.   this.NOTIFY_ALERT_CLICKED  = "gmanager-alert-notify-clicked";
  8.   this.NOTIFY_ALERT_FINISHED = "gmanager-alert-notify-finished";
  9.   
  10.   this.ALERT_WINDOW_NAME = "gmanager-alert";
  11.   
  12.   this.display = function(aEmail)
  13.   {
  14.     var manager = Components.classes["@longfocus.com/gmanager/manager;1"].getService(Components.interfaces.gmIManager);
  15.     var account = manager.getAccount(aEmail);
  16.     
  17.     if (!this._accounts)
  18.       this._accounts = new Array();
  19.     
  20.     if (account)
  21.     {
  22.       var accountExists = false;
  23.       
  24.       for (var i = 0; i < this._accounts.length && !accountExists; i++)
  25.       {
  26.         if (this._accounts[i].email == account.email)
  27.           accountExists = true;
  28.       }
  29.       
  30.       if (!accountExists)
  31.       {
  32.         this._accounts.push(account);
  33.         
  34.         if (!gmanager_Utils.isWindow(this.ALERT_WINDOW_NAME))
  35.           this._displayNext();
  36.       }
  37.     }
  38.   }
  39.   
  40.   this._displayNext = function()
  41.   {
  42.     if (this._accounts && this._accounts.length > 0)
  43.     {
  44.       var account = this._accounts.shift();
  45.       window.openDialog("chrome://gmanager/content/alert/alert.xul", this.ALERT_WINDOW_NAME, "chrome,dialog=yes,titlebar=no,popup=yes", account, this);
  46.     }
  47.   }
  48.   
  49.   this.observe = function(aSubject, aTopic, aData)
  50.   {
  51.     switch (aTopic)
  52.     {
  53.       case this.NOTIFY_ALERT_CLICKED:
  54.       {
  55.         // aSubject : null
  56.         // aTopic   : gmanager_Alerts.NOTIFY_ALERT_CLICKED
  57.         // aData    : email (e.g. longfocus@gmail.com)
  58.         
  59.         // Load the account inbox
  60.         gmanager_Accounts.loadInbox(aData, "background");
  61.         
  62.         break;
  63.       }
  64.       case this.NOTIFY_ALERT_FINISHED:
  65.       {
  66.         // aSubject : null
  67.         // aTopic   : gmanager_Alerts.NOTIFY_ALERT_FINISHED
  68.         // aData    : email (e.g. longfocus@gmail.com)
  69.         
  70.         // Display the next alert (if available)
  71.         this._displayNext();
  72.         
  73.         break;
  74.       }
  75.       default:
  76.         break;
  77.     }
  78.   }
  79. }